package org.jeecg.modules.mg.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.annotations.Cache;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.mg.entity.SecurityCode;
import org.jeecg.modules.mg.service.ISecurityCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author dinggang
 * @since 2021-02-15
 */
@RestController
@RequestMapping("/mg/security-code")
@Api(tags = "股票代码")
public class SecurityCodeController {

    @Autowired
    private ISecurityCodeService securityCodeService;

    @GetMapping("/getUserByName")
    @ApiOperation("测试")
    public Result<?> getUserByName(@RequestParam("username") String username) {
        return Result.OK("TEST");
    }

    @GetMapping("/code/all")
    @ApiImplicitParams(@ApiImplicitParam(name = "name", required = false))
    @ApiOperation("所有股票代码")
    public Result<?> allCode(@RequestParam(value = "name", required = false) String name) {
        return Result.OK(securityCodeService.list(new LambdaQueryWrapper<SecurityCode>().select(SecurityCode::getName, SecurityCode::getTsCode).like(!StringUtils.isEmpty(name), SecurityCode::getName, name)));
    }


}

